package com.ibp.quartz;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.print.attribute.HashAttributeSet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.ibp.dao.IbpEventLogDataMapper;
import com.ibp.entity.IbpEventLogData;
import com.ibp.service.IbpEventLogDataService;

public class QuartzTradeLog {
	
	private Logger logger = LoggerFactory.getLogger(QuartzTradeLog.class);
	@Autowired																							
	IbpEventLogDataMapper ibpEventLogDataMapper ;
	
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/ HH:mm:ss");
	Map map = new HashMap();
	/**
	 * 统计每分钟
	 */
	public void executeByMinutes(){
		Date date = new Date();
		logger.info(sdf.format(date)+"每分钟================");
		IbpEventLogData elog = new IbpEventLogData();
		elog.setYmd(sdf.format(date));
		elog.setLogType("M");
		map.put("logType", elog.getLogType());
		map.put("ymd", elog.getYmd());
		long mms = System.currentTimeMillis();
		ibpEventLogDataMapper.tradeCountforS(elog);
		logger.info("s======>"+(System.currentTimeMillis()-mms));
		
		ibpEventLogDataMapper.tradeCountforS10(elog);
		
		logger.info("10s======>"+(System.currentTimeMillis()-mms));
		
		ibpEventLogDataMapper.tradeCountforM(elog);
		
		logger.info("M======>"+(System.currentTimeMillis()-mms));
		
		ibpEventLogDataMapper.tradeCountforM10(elog);
		
		logger.info("10M======>"+(System.currentTimeMillis()-mms));
		ibpEventLogDataMapper.tradeCountforH(elog);
		
		logger.info("H======>"+(System.currentTimeMillis()-mms));
		ibpEventLogDataMapper.tradeCountforD(elog);
		logger.info("D======>"+(System.currentTimeMillis()-mms));
	}
	
	/**
	 * 每秒执行一次插入测试数据
	 */
	public void executeBySeconds(){
		logger.info("每秒钟================");
		Date date = new Date();
		IbpEventLogData elog = new IbpEventLogData();
		elog.setYmd(sdf.format(date));
		elog.setLogType("M");
		map.put("logType", elog.getLogType());
		map.put("ymd", elog.getYmd());
		ibpEventLogDataMapper.tradeCountSeconds(map);
		
	}
	
	
	
	
	
	/**
	 * 统计每小时
	 *//*
	public void executeByHours(){
		Date date = new Date();
		IbpEventLogData elog = new IbpEventLogData();
		elog.setYmd(sdf.format(date));
		elog.setLogType("H");
		map.put("logType", elog.getLogType());
		map.put("ymd", elog.getYmd());
		ibpEventLogDataMapper.tradeCount(map);
		logger.info(sdf.format(date)+"每小时================");
	}
	
	*//**
	 * 统计每天凌晨0点
	 *//*
	public void executeByDay(){
		Date date = new Date();
		IbpEventLogData elog = new IbpEventLogData();
		elog.setYmd(sdf.format(date));
		elog.setLogType("D");
		map.put("logType", elog.getLogType());
		map.put("ymd", elog.getYmd());
		
		ibpEventLogDataMapper.tradeCount(map);
		logger.info(sdf.format(date)+"===0点================"+elog.getLogType());
	}*/
}
